<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>项目申请</title>
    <!-- 引入element-ui样式 -->
    <link rel="stylesheet" href="../../../plugins/element-ui/index.css">

</head>
<body>

<div id="app">
    <el-container style="height: 800px; border: 1px solid #eee">
        <el-container>
            <div style="width: 100%;position: relative">

                <div style=";margin-bottom: 80px;">

                </div>

                <el-table   size="medium" current-row-key="id"  :data="dataList" stripe highlight-current-row>
                    <el-table-column type="index" align="center" label="序号"></el-table-column>
                    <el-table-column prop="name" label="工程名" align="center"></el-table-column>
                    <el-table-column prop="applyForFunds" label="申请资金" align="center"></el-table-column>
                    <el-table-column prop="type" label="工程类型" align="center"></el-table-column>
                    <el-table-column prop="jobNumber" label="工号" align="center"></el-table-column>
                    <el-table-column prop="phone" label="联系电话" align="center"></el-table-column>
                    <el-table-column prop="file" label="附件名" align="center"></el-table-column>
                    <el-table-column prop="statusOne" label="状态1" align="center"></el-table-column>
                    <el-table-column prop="statusTwo" label="状态2" align="center"></el-table-column>
                    <el-table-column label="操作" align="center">
                        <template slot-scope="scope">
                            <el-button type="primary" size="mini" @click="down(scope.row)">下载</el-button>
                            <el-button type="danger"  size="mini" @click="updateStatusOne(scope.row,1)">通过</el-button>
                            <el-button type="warning"  size="mini" @click="updateStatusOne(scope.row,2)">否定</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                
                <!--分页组件-->
                <el-pagination
                        class="pagination"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>



            </div>
        </el-container>
    </el-container>
</div>


<script src="../../../plugins/vue/vue.js"></script>

<!-- 引入element-ui组件库 -->
<script src="../../../plugins/element-ui/index.js"></script>

<!-- 引入axios -->
<script src="../../../plugins/axios/axios.min.js"></script>

<script>

    new Vue({
        el:'#app',    //element
        data:{


            adminTwoInfo1:{}, //当前用户信息

            //显示的数据
            dataList:[],

            //element-ui分页插件
            pagination: {//分页相关模型数据 1
                currentPage: 1,//当前页码1
                pageSize:5,//每页显示的记录数1
                total:0,//总记录数1
            },


            //修改弹框内容
            formData_update:{
                file:"",
            },
            dialog_update:false,


            //新增弹框内容
            formData_add:{
                file:"",
                major:"",
            },
            dialog_add:false,

            options1: [{
                value: '科研',
                label: '科研'
            },{
                value: '论文',
                label: '论文'

            },{
                value: ' 教改',
                label: ' 教改'

            },],

            status:"否定",


            //文件上传
            fileList: [
                {name: '', url: ''}
            ],

        },
        created() {
            const adminTwoInfo = window.localStorage.getItem('adminTwo')
            console.log("adminTwoInfo1:::"+adminTwoInfo)
            if (adminTwoInfo) {
                this.adminTwoInfo = JSON.parse(adminTwoInfo)
            }
            console.log("adminTwoInfo2:::"+adminTwoInfo)

            this.getAll();

        },
        methods:{

            getAll(){
                console.log("uuid")
                console.log(this.adminTwoInfo.data)
                console.log(this.adminTwoInfo.data.jobNumber)

                axios.get("/projects/getPageProject/"+this.pagination.currentPage+"/"+this.pagination.pageSize).then((res)=>{
                    console.log(res)
                    this.dataList=res.data.data.records
                    this.pagination.total=res.data.data.total

                    for (var i = 0; i < res.data.data.records.length; i++) {
                       if ( res.data.data.records[i].statusTwo=="通过"){
                           this.status="不通过"
                       }else {
                           this.status="通过"
                       }
                    }
                })
            },

            //切换页码
            handleCurrentChange(currentPage) {
                console.log("切换页码:")
                this.pagination.currentPage=currentPage;
                console.log(currentPage)
                this.getAll();
            },


            //下载
            down(row){
                console.log("row")
                    console.log(row)
                if (row.file!=null){
                    window.location.href="http://localhost:8080/files/downloadFile2?name="+row.file
                }else {
                    this.$message.error("没有附件下载")
                }
            },


            updateStatusOne(row,code){
                console.log(row)
                if (code==1){
                    row.statusTwo="通过"
                }else if (code==2){
                    row.statusTwo="不通过"
                }
                axios.put("/projects/updateProject",row).then((res)=> {
                    console.log("deleteById:")
                    console.log(res)
                    if (res.data.code){
                        this.$message.success(res.data.msg)
                    }else{
                        this.$message.error(res.data.msg)
                    }
                }).finally(()=>{
                    this.getAll()
                })
            },

            center() {
                this.dialog_update=false
                this.dialog_add=false
                this.$message.info("取消操作")
            },

            /**
             * 文件上传
             *
             */
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePreview(file) {
                console.log(file);
            },
            handleAvatarSuccess(res, file) {
                 console.log("res,file")
                 console.log(res)
                 console.log(file)
                this.formData_add.file=res.data
                this.formData_update.file=res.data
            },
        }
    })

</script>
</body>
</html>




